home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7082 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  878 b 

  1. Path: Door.lotus.com!verma1
  2. From: vverma@crd.lotus.com (Virendra Verma)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: problem: static data in classes
  5. Date: 20 Feb 1996 18:44:47 GMT
  6. Organization: Lotus Development
  7. Message-ID: <4gd4qv$kdn@Door.lotus.com>
  8. References: <9602180123.AA22010@dcc11748.slip.digex.net>
  9. NNTP-Posting-Host: 130.103.39.48
  10. X-Newsreader: News Xpress Version 1.0 Beta #3
  11.  
  12. In article <9602180123.AA22010@dcc11748.slip.digex.net>,
  13.    yami@digex.net (Steven D. Arnold) wrote:
  14.  
  15. >class sample
  16. >{
  17. >        public:
  18. >                sample();
  19. >
  20. >        private:
  21. >                static int count;
  22. >};
  23. >
  24.  
  25. You need to create the definition of sample::count. static members don't get 
  26. created when instanciating a class. By definition, static members have only 
  27. one copy. You need to create that copy separately. Put the following line
  28. in your .c file
  29.  
  30. int sample::count = 0
  31.  
  32.  
  33.